package com.atguigu.tingshu.album.api;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.BaseAttribute;
import com.atguigu.tingshu.model.album.BaseAttributeValue;
import com.atguigu.tingshu.model.album.BaseCategoryView;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jdk.jfr.Description;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value = "/api/album/category")
@SuppressWarnings({"unchecked", "rawtypes"})
public class BaseCategoryApiController {

    @Autowired
    private BaseCategoryService baseCategoryService;


    @Operation(summary = "三级分类")
    @GetMapping("getBaseCategoryList")

    public Result<List<JSONObject>> getBaseCategoryList() {

        List<JSONObject> jsonObjects = this.baseCategoryService.getBaseCategoryList();

        return Result.ok(jsonObjects);
    }

    //  Request URL: http://127.0.0.1:8500/api/album/category/findAttribute/1
    @Operation(summary = "查询标签属性值")
    @GetMapping("findAttribute/{categoryId1}")
    public Result<List<BaseAttribute>> findAttribute(@PathVariable("categoryId1") Long categoryId1) {
        List<BaseAttribute> attributes = this.baseCategoryService.findAttribute(categoryId1);
        return Result.ok(attributes);
    }

@Operation(summary = "内部接口：查询三级分类查询一二三级分类")
@GetMapping("getBaseCategoryViewByCategory3Id/{category3Id}")
    public Result<BaseCategoryView>   getBaseCategoryViewByCategory3Id(@PathVariable Long category3Id){
   return Result.ok(baseCategoryService.getBaseCategoryViewByCategory3Id(category3Id));


}


}

